package com.lglbc.factory.abs;

import com.lglbc.factory.entity.Car;

import java.util.Objects;
import java.util.Scanner;
/**
 * @author： 乐哥聊编程(全平台同号)
 */
public class Test {
    public static void main(String[] args) {

        while (true){
            CarFactory carFactory =null;
            System.out.println("请问需要什么颜色的汽车？yellow or black?");
            Scanner input = new Scanner(System.in);
            String color=input.next();//读取输入的字符串
            if (color.equals("yellow")){
                carFactory = new YellowCarFactory();
            }else if(color.equals("black")){
                carFactory = new BlackCarFactory();
            }else{
                System.out.println("没有此类颜色的车");
                continue;
            }
            Car car = null;
            System.out.println("请问需要什么型号的汽车？1 or 2?");
            input = new Scanner(System.in);
            String type=input.next();//读取输入的字符串
            if (type.equals("1")){
                car = carFactory.createCar1();
            }else if(type.equals("2")){
                car = carFactory.createCar2();
            }else{
                System.out.println("没有此类型号的车");
                continue;
            }
            if (Objects.nonNull(car)){
                car.carColor();
                car.carSpeed();
                car.carPrice();
            }
        }
    }
}